import React from "react";
import { connect } from "dva";
import { Button,Input } from 'antd';
import _ from 'lodash';

class Home extends React.PureComponent{
  constructor(props){
    super(props);
    this.state = {};
  }

  componentDidMount = () => {
    console.log(this);
  }

  getInputProps = () => {
    return {
      disabled: true,
      value: _.get(this.props,'pageState.num'),
      style: {
        width: '100px',
      }
    }
  }
  
  render = () => {
    return <div>
      <Button onClick={()=>this.props.dispatch({type: 'home/sub'})}>-1</Button>
      <Input {...this.getInputProps()}/>
      <Button onClick={()=>this.props.dispatch({type: 'home/add'})}>+1</Button>
    </div>
  }
}

export default connect((state) => ({
  pageState: state.home,
}))(Home);

